/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author core i5
 */
public class ConexionReporte {
    
    private Connection con;
    private String driver;
    private String url;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Connection getCon() {
        return con;
    }

    public void setCon(Connection con) {
        this.con = con;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    private String user;
    private String password;
    
    public ConexionReporte(){
        this.driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; 
        this.url = "jdbc:sqlserver://inti.lab.inf.pucp.edu.pe:1433;databaseName=inf226g4";
        this.user = "inf226g4usr";
        this.password = "4m0adawn";
    }

    public void setearConexion() throws ClassNotFoundException, SQLException {
        Class.forName(this.driver);
        this.con = DriverManager.getConnection(getUrl(), this.user , this.password);
    }
    
    public void SetearConexion() throws ClassNotFoundException{
    try {
            Class.forName(driver);
            con = DriverManager.getConnection(getUrl(), user , password);

        }
        catch ( SQLException e ) {
            JOptionPane.showMessageDialog(null,e.getMessage());
        }

    }

    public void cerrarConexion() {
        try {
            getCon().close();
        }
        catch( SQLException e ){
            System.out.println(e.getMessage());
        }
    }
    
}
